package org.ajax.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.ajax.dao.GoodsDao;
import org.ajax.dao.impl.GoodsDaoImpl;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author CSY
 * @date 2024-11-20
 */
@WebServlet("/del.do")
public class GoodsDelServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String goodId = req.getParameter("goodId");

        GoodsDao dao = new GoodsDaoImpl();

        int n = dao.deleteGood(goodId);

        PrintWriter out = resp.getWriter();

        out.println(n);

        out.flush();
        out.close();
    }
}
